home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig16_19.jar / Ch16 / Fig16_19 / Fig16_19.cpp
C/C++ Source or Header  |  1997-11-10  |  2KB  |  45 lines

  1. // Fig. 16.19: fig16_19.cpp
  2. // Using functions isspace, iscntrl, ispunct, isprint, isgraph
  3. #include <iostream.h>
  4. #include <ctype.h>
  5.  
  6. int main()
  7. {
  8.    cout << "According to isspace:\nNewline " 
  9.         << ( isspace( '\n' ) ? "is a" : "is not a" )
  10.         << " whitespace character\nHorizontal tab " 
  11.         << ( isspace( '\t' ) ? "is a" : "is not a" )
  12.         << " whitespace character\n"
  13.         << ( isspace( '%' ) ? "% is a" : "% is not a" )
  14.         << " whitespace character\n";
  15.  
  16.    cout << "\nAccording to iscntrl:\nNewline " 
  17.         << ( iscntrl( '\n' ) ? "is a" : "is not a" )
  18.         << " control character\n"
  19.         << ( iscntrl( '$' ) ? "$ is a" : "$ is not a" )
  20.         << " control character\n";
  21.  
  22.    cout << "\nAccording to ispunct:\n"
  23.         << ( ispunct( ';' ) ? "; is a" : "; is not a" )
  24.         << " punctuation character\n"
  25.         << ( ispunct( 'Y' ) ? "Y is a" : "Y is not a" )
  26.         << " punctuation character\n"
  27.         << ( ispunct('#') ? "# is a" : "# is not a" )
  28.         << " punctuation character\n";
  29.  
  30.    cout << "\nAccording to isprint:\n"
  31.         << ( isprint( '$' ) ? "$ is a" : "$ is not a" )
  32.         << " printing character\nAlert " 
  33.         << ( isprint( '\a' ) ? "is a" : "is not a" )
  34.         << " printing character\n";
  35.  
  36.    cout << "\nAccording to isgraph:\n"
  37.         << ( isgraph( 'Q' ) ? "Q is a" : "Q is not a" )
  38.         << " printing character other than a space\nSpace " 
  39.         << ( isgraph(' ') ? "is a" : "is not a" )
  40.         << " printing character other than a space" << endl;
  41.  
  42.    return 0;
  43. }
  44.  
  45.